angular.module('todoApp').directive('todoHeader', function() {
  return {
    templateUrl: './directives/todoHeader.html',
    scope: {
      onAdd: '&onAdd',
      onChangeOrder: '&onChangeOrder'
    },
    link: function(scope) {
      scope.content = '';
      scope.ascend = true;
      scope.addItem = function() {
        scope.onAdd({ content: scope.content });
        scope.content = '';
      };
      scope.changeOrder = function() {
        scope.onChangeOrder({ascend: scope.ascend});
        scope.ascend = !scope.ascend;
      };
    }
  };
});